<template>
    <div>
      全选
      <input type="checkbox" v-model="isAll">
      <br>
      <ul>
        <li v-for="obj in personList" :key="obj.id">
          <input type="checkbox" v-model="obj.isChecked">
          {{ obj.name }}
        </li>
      </ul>
    </div>
  </template>
  
  <script>
  export default {
    data(){
      return{
        personList: [{
          id: '1111',
          name: '猪八戒',
          isChecked: false,
        },{
          id: '222',
          name: '孙悟空',
          isChecked: false,
        },{
          id: '3333',
          name: '唐僧',
          isChecked: false,
        },{
          id: '4444',
          name: '白龙马',
          isChecked: false,
        }]
      }
    },
    computed:{
      isAll: {
        get(){
          return this.personList.every(obj => obj.isChecked)
        },
        set(val){
          this.personList.forEach(obj => obj.isChecked = val)
        }
      }
    }
  }
  </script>
  
  <style>
  
  </style>